//
//  BSMacros.h
//  DYHospital
//
//  Created by 胡金东 on 16/3/19.
//  Copyright © 2016年 胡金东. All rights reserved.

//

#import <Foundation/Foundation.h>

#pragma mark -
#pragma mark Common Macros

/**
 * Logs
 */
#ifdef DEBUG
#define DLog(fmt, ...) {NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);}
#define ELog(err) {if(err) DLog(@"%@", err)}
#else
#define DLog(...)
#define ELog(err)
#endif

/**
 * Creates an opaque UIColor object from a byte-value color definition.
 @code
 UIColor* color = RGBCOLOR(255, 128, 64); // Fully opaque orange
 UIColor* color = RGBACOLOR(255, 128, 64, 0.5); // Orange with 50% transparency
 UIColor* color = RGBCOLOR(0xFF, 0x7A, 0x64); // Hexadecimal color
 @endcode
 */
#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]

/**
 * Creates a UIColor object from a byte-value color definition and alpha transparency.
 */
#define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]


/**
 * 获取App的版本号
 */
#define APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
#define APP_BVERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]

/**
 * 获取系统的版本号
 */
#define SYS_VERSION [UIDevice currentDevice].systemVersion

/**
 * UI constants
 */
#define UI_STATUS_BAR_HEIGHT ([[UIApplication sharedApplication] statusBarFrame].size.height)
#define UI_NAVIGATION_BAR_HEIGHT    44
#define UI_TOOL_BAR_HEIGHT          44
#define UI_TAB_BAR_HEIGHT           49
#define UI_SCREEN_WIDTH             ([[UIScreen mainScreen] bounds].size.width)
#define UI_SCREEN_HEIGHT            ([[UIScreen mainScreen] bounds].size.height)

// 设备判断
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)
#define SCREEN_MAX_LENGTH (MAX(UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT))
#define SCREEN_MIN_LENGTH (MIN(UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT))

#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
#define IS_IPHONE_6_PLUS (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)

// iOS7判断
#define IS_IOS_7 [[[SYS_VERSION componentsSeparatedByString:@"."] objectAtIndex:0] intValue] >= 7
#define IOS_VERSION_LOW_7 !(IS_IOS_7)

// i18n
#define i18n(key)  [[BSLocalisationManager sharedInstance] localizedStringForKey:(key)]



// 默认的页面背景色
#define kDefaultBackgroundColor     RGBCOLOR(240, 240, 240)

// MKNetworkKitRequestTimeOutInSeconds 默认为30s，如果需要修改，在MKNetworkKit.h头文件中修改
#define SERVER_TIMEOUT  30.0
// HTTP配置
#define HTTP_METHOD_POST    @"POST"
#define HTTP_METHOD_GET    @"GET"
#define HTTP_METHOD_DELETE    @"DELETE"
#define HTTP_METHOD_PUT    @"PUT"
